import type { TodoType } from "./store.ts";

export type ActionType = {
    type: string
    payload?: any
}

export default function reducer(state: TodoType[], action: ActionType){
    switch(action.type){
        case 'add':
            return state.concat(action.payload)
        case 'delete':
            console.log('action'),action
            return state.filter(todo => todo.id !== action.payload )
        default:
            throw new Error()
    }
}